// 文章模块接口

import myRequest from './index'
//获取文章列表(/api/articles)
export const getArticleListAPI = () => {
  return myRequest.get('/api/articles')
}
//创建新文章(/api/articles)
export const createArticleAPI = (data) => {
  return myRequest.post('/api/articles', data)
}
//编辑文章(/api/articles /:articleId)
export const updateArticleAPI = (articleId, data) => {
  return myRequest.post(`/api/articles/${articleId}`, data)
}
//删除文章(/api/articles /: articleId)
export const deleteArticleAPI = (articleId) => {
  return myRequest.delete(`/api/articles/${articleId}`)
}
//获取文章详情(/api/articles /: articleId)
export const getArticleDetailAPI = (articleId) => {
  return myRequest.get(`/api/articles/${articleId}`)
}
//点赞文章(/api/articles /: articleId / like)
export const likeArticleAPI = (articleId) => {
  return myRequest.post(`/api/articles/${articleId}/like`)
}
//评论文章(/api/articles /: articleId / comments)
export const commentArticleAPI = (articleId, data) => {
  return myRequest.post(`/api/articles/${articleId}/comments`, data)
}
//删除评论(/api/articles /: articleId / comments /: commentId)
export const deleteCommentAPI = (articleId, commentId) => {
  return myRequest.delete(`/api/articles/${articleId}/comments/${commentId}`)
}
//收藏文章(/api/articles /: articleId / favorite)
export const favoriteArticleAPI = (articleId) => {
  return myRequest.post(`/api/articles/${articleId}/favorite`)
}
//获取用户收藏的文章列表(/api/users /: userId / favorites)
export const getFavoriteArticleListAPI = (userId) => {
  return myRequest.get(`/api/users/${userId}/favorites`)
}
//获取文章点赞数(/api/articles /: articleId / likes)
export const getArticleLikesAPI = (articleId) => {
  return myRequest.get(`/api/articles/${articleId}/likes`)
}
